home *** CD-ROM | disk | FTP | other *** search
/ NeXT Education Software Sampler 1992 Fall / NeXT Education Software Sampler 1992 Fall.iso / Programming / Source / IP_Graph3D / GraphController.m < prev    next >
Encoding:
Text File  |  1991-10-10  |  2.7 KB  |  198 lines

  1.  
  2. /* Generated by Interface Builder */
  3.  
  4. #import "GraphController.h"
  5. #import "GraphView.h"
  6. #import <appkit/appkit.h>
  7. #import <math.h>
  8.  
  9. void function1(detail, anArray)
  10.    int detail;
  11.    bigArray anArray;
  12. {
  13.     int i=0,j=0;
  14.     float count=0.0;
  15.     
  16.     count=PI/detail*4;
  17.     for (i=0; i < detail; i++)
  18.     {
  19.         for (j=0; j < detail; j++)
  20.         {
  21.             /*anArray[i][j]=(float) sin(i*count)*cos(j*count);
  22.             */
  23.         }
  24.     }
  25. }
  26.  
  27. void function2(detail, anArray)
  28.    int detail;
  29.    bigArray anArray;
  30. {
  31. }
  32.  
  33. void function3(detail, anArray)
  34.    int detail;
  35.    bigArray anArray;
  36. {
  37. }
  38.  
  39.  
  40.  
  41.  
  42.  
  43. @implementation GraphController
  44.  
  45. - init
  46. {
  47.     [super init];
  48.     curGraph=1;
  49.     [self writeDetail:10];
  50.     [self writeSize:200];
  51.     [self writeTheta:0];
  52.     [self writePhi:0];
  53.     graphArray = (bigArray) malloc(sizeof(float)*detail*detail);
  54.     function1(detail, graphArray);
  55.     [thetaDisplayPtr setIntValue:[self readTheta]];
  56.     [phiDisplayPtr setIntValue:[self readPhi]];
  57.     return self;
  58. }
  59.  
  60. - appDidInit: sender
  61. {
  62.     [[graphViewPtr window] makeKeyAndOrderFront:self];
  63.     return self;
  64. }
  65.  
  66.  
  67. - selectFunction:sender
  68. {
  69.     curGraph = [sender selectedCol];
  70.     switch (curGraph)
  71.     {
  72.         case 1 : function1(detail, graphArray);
  73.         case 2 : function2(detail, graphArray);
  74.         case 3 : function3(detail, graphArray);
  75.     }
  76.     return self;
  77. }
  78.  
  79. - changePerspective: sender
  80. {
  81.     [self writePerspective: [sender floatValue]];
  82.     [graphViewPtr display];
  83.     return self;
  84. }
  85.  
  86. - slideThetaSlider: (int)val
  87. {
  88.     [thetaSliderPtr setIntValue:val];
  89.     return self;
  90. }
  91.  
  92. - slidePhiSlider: (int)val
  93. {
  94.     [phiSliderPtr setIntValue:val];
  95.     return self;
  96. }
  97.  
  98. - updateThetaSlider: sender
  99. {
  100.     [self writeTheta:[sender intValue]];
  101.     [graphViewPtr display];
  102.     return self;
  103. }
  104. - updatePhiSlider: sender
  105. {
  106.     [self writePhi:[sender intValue]];
  107.     [graphViewPtr display];
  108.     return self;
  109. }
  110. - updateSizeSlider: sender
  111. {
  112.     [self writeSize:[sender intValue]];
  113.     [graphViewPtr display];
  114.     return self;
  115. }
  116. - updateDetailSlider: sender
  117. {
  118.     [self writeDetail:[sender intValue]*2];
  119.     [graphViewPtr display];
  120.     return self;
  121. }
  122.  
  123. - (int) readCurGraph
  124. {
  125.     return curGraph;
  126. }
  127.  
  128. - (int) readSize
  129. {
  130.     return scale;
  131. }
  132.  
  133. - (int) readDetail
  134. {
  135.     return detail;
  136. }
  137.  
  138. - (int) readTheta
  139. {
  140.     return theta;
  141. }
  142.  
  143. - (int) readPhi
  144. {
  145.     return phi;
  146. }
  147.  
  148. - (float) readPerspective
  149. {
  150.     return perspective;
  151. }
  152.  
  153. - (bigArray) readGraphArray
  154. {
  155.     return graphArray;
  156. }
  157.  
  158. - writeCurGraph: (int) val
  159. {
  160.     curGraph = val;
  161.     return self;
  162. }
  163.  
  164. - writeSize: (int) val
  165. {
  166.     scale=val;
  167.     [sizeDisplayPtr setIntValue:val];
  168.     return self;
  169. }
  170.  
  171. - writeDetail: (int) val
  172. {
  173.     detail = val;
  174.     [detailDisplayPtr setIntValue:val];
  175.     return self;
  176. }
  177.  
  178. - writeTheta:(int) val
  179. {
  180.     theta = val;
  181.     [thetaDisplayPtr setIntValue:val];
  182.     return self;
  183. }
  184.  
  185. - writePhi:(int) val;
  186. {
  187.     phi = val;
  188.     [phiDisplayPtr setIntValue:val];
  189.     return self;
  190. }
  191.  
  192. - writePerspective:(float) val
  193. {
  194.     perspective = val;
  195.     return self;
  196. }
  197. @end
  198.